package com.keqiongzc.module_main

import android.os.Bundle
import androidx.activity.viewModels
import androidx.lifecycle.Observer
import com.alibaba.android.arouter.facade.annotation.Autowired
import com.alibaba.android.arouter.facade.annotation.Route
import com.alibaba.android.arouter.launcher.ARouter
import com.everyline.lib_base.base.BaseViewModel
import com.everyline.lib_base.ext.parseState
import com.everyline.lib_common.base.BaseActivity
import com.everyline.lib_common.global.ConfigKeys
import com.everyline.lib_common.global.Configurator
import com.everyline.lib_common.router.RouterPath
import com.everyline.lib_common.service.LoginService
import com.everyline.lib_common.service.wrap.LoginServiceImplWrap
import com.keqiongzc.module_main.databinding.MainActivityMainBinding

/**
 * Created by on 2021/2/27.
 * 天天挂线
 *  746608431@qq.com
 *  描述:TODO
 */

@Route(path = RouterPath.Home.PATH_HOME)
class MainActivity : BaseActivity<BaseViewModel, MainActivityMainBinding>() {
    val requestVersionModel by viewModels<RequestVersionModel>()

    override fun initListener() {

    }

    override fun createObserver() {
        requestVersionModel.versionData.observe(this, Observer { data ->
            parseState(data, {

            }, {})

        })

    }

    override fun getTitleBar(): Int = 0

    override fun initView(savedInstanceState: Bundle?) {
        ARouter.getInstance().inject(this)


    }

    override fun initData() {
        mViewBinding.tvContent.text =
            "${LoginServiceImplWrap!!.isLogin()}===${LoginServiceImplWrap.getUserInfo()!!.driverName}"
        getAppVersion()

    }

    override fun getLayoutResId(): Int = R.layout.main_activity_main

    protected fun getAppVersion() {
        val map = hashMapOf<String, String>()

        map["appSystem"] = "2"
        map["appSource"] = Configurator.instance.getConfiguration<String>(
            ConfigKeys.APP_SOURCE
        )
        requestVersionModel.getAppVersion(map)

    }

}